# encoding:utf-8

import os
import shutil
import logging
import string
import json
from pylibs import LuaGame



class HotPack(object):

    _config = None

    @classmethod
    def __init_conf(cls, jsonfile):
        ''' 初始化配置 '''
        jfile = open(jsonfile, "r")
        conf = json.loads(jfile.read().decode("utf-8"))
        jfile.close()

        cls._config = dict()
        try:
            cls._config["svnpath"] = conf["svnpath"]
            cls._config["respath"] = conf["respath"]
            cls._config["litver"]   = conf["litver"]
            cls._config["svn_s"] = conf["svn_s"]
            cls._config["svn_e"] = conf["svn_e"]
            cls._config["os"] = conf["os"]
            cls._config["tarpath"] = conf["tarpath"]

        except KeyError, keyer:
            logging.error("Check the config key again!\n%s", keyer)

    @classmethod
    def excute(cls, projpath, toolpath, jsonfile):
        ''' 执行 '''
        cls._config = cls.__init_conf(jsonfile)
        LuaGame.svn_difflist(cls._config["respath"], cls._config["svn_s"], cls._config["svn_e"], \
                                cls._config["tarpath"], cls._config["os"])



if __name__ == "__main__":
    print("======================================")
    print("===============HotPack=================")
    print("======================================")

    # parser = OptionParser() 
    # parser.add_option("-c", "--hotconf", dest="hotconf", default=None, help="Input the hotupdate configfile!")
    # (opts, args) = parser.parse_args()
    # if (opts.hotconf):


    kk = dict(aa = 1)
    print (kk["c"])